
<div class="widget-container">
    <?php
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        'id' => 'product-form',
        'htmlOptions' => array(
            'enctype' => 'multipart/form-data',
            'class' => 'form-horizontal'
        ),
    ));
    ?>
    <?php echo CHtml::errorSummary($model); ?>
    <div class="btn-group btn-group-admin">
        <?php
        if ($model->getScenario() == 'update') {
            echo Chtml::link('Thêm mới', array('create'), array('class' => 'btn btn-primary'));
            echo Chtml::link('Xóa', array('delete', 'id' => $model->id), array('class' => 'btn btn-primary'));
        } else {
            echo Chtml::link('Danh sách', array('index'), array('class' => 'btn btn-primary'));
        }
        ?>
    </div>

    <div class="widget-box">
        <div class="widget-content nopadding">
            <?php
            if (!empty($listData)) {
                ?>
                <div class="control-group">
                    <?php echo $form->labelEx($model, 'category_id', array('class' => 'control-label')); ?>
                    <div class="controls">
                        <?php echo $form->dropDownList($model, 'category_id', $listData); ?>
                        <?php echo $form->error($model, 'category_id'); ?>
                    </div>
                </div>
            <?php } ?>
            <div class="control-group">
                <?php echo $form->labelEx($model, 'name', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php
                    echo $form->textField($model, 'name', array('class' => 'span8'));
                    ?>
                    <?php echo $form->error($model, 'name'); ?>
                </div>
            </div>
            <div class="control-group">
                <?php echo $form->labelEx($model, 'file', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php
                    echo $form->fileField($model, 'file', array('class' => 'span8'));
                    ?>
                    <?php echo $form->error($model, 'file'); ?>
                </div>
            </div>
            

            <div class="control-group">
                <?php echo $form->labelEx($model, 'status', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php echo $form->checkBox($model, 'status', array('value' => '1', 'checked' => 'checked')); ?>
                    <?php echo $form->error($model, 'status'); ?>
                </div>
            </div>

        </div>
    </div>



    <div class="control-group">
        <div class="controls">
            <?php echo CHtml::submitButton('Thêm mới', array('class' => 'btn btn-success')); ?>
        </div>
    </div>


    <?php
    $this->endWidget();
    ?>

</div><!-- form -->

<script>
    $(function() {
        $('#News_name').keyup(function() {
            title = $('#News_name').val();
            $('#News_alias').val(convertToSlug(title));
        });
    });
</script>